<template>
  <div ref="djrzA5">
    <div class="temp_plate print-wrap-210 print-wrap-normal" style="width: 210mm;font-size: 12px;
        padding: 10px;
        border: 1px solid #a5a5a5;
        box-shadow: 2px 2px 2px #d3d3d3;text-align: left;">
      <h2 style="text-align:center; ">
        {{seller.name?seller.name:'酒店'}}登记单
      </h2>

      <p class="panelone panelone2">
        <span>打印时间:</span>
        <span>{{ nowDate + ' ' + nowTime + ' ' }}</span>
        <span>打印人:</span>
        <span>{{ user ? user.username : '易信' }}</span>
      </p>
      <p class="panelone panelone2" style="margin-bottom: 5px;">
        <span>单号:</span>
        <span v-if="type == 2">R2019090101</span>
        <span v-else>{{ changInfo.singleEntity.sysNo ? changInfo.singleEntity.sysNo : '--' }}</span>
        <span>登记人:</span>
        <span>{{ user ? user.username : '易信' }}</span>
      </p>

      <table style="font-size:13px; border:1px solid #000;text-align: center; border-collapse: collapse; padding:2px;width:100%;margin-bottom: 10px;">

        <template v-if="type == 2">
          <tr>
            <td style="border:1px solid #000;" colspan="2">
              <span>大床房</span>
            </td>
            <td style="border:1px solid #000;" colspan="1">
              <span>门市价：198</span>
            </td>
            <td style="border:1px solid #000;" colspan="1"><span>优惠房价：168</span></td>
            <td colspan="1" style="border:1px solid #000;">
              <span>
                客人来源: 美团
              </span>
            </td>
          </tr>
        </template>

        <template v-else>
          <template v-for="(item,index) in changInfo.ruZhuPrintingRoomVos">
            <tr>
              <td style="border:1px solid #000;" colspan="2">
                <span>{{ item.roomName ? item.roomName : '--' }}</span>
                <span> {{ item.roomNum ? item.roomNum : '--' }}</span>
              </td>
              <td style="border:1px solid #000;" colspan="1">
                <span>门市价:{{ item.oprice ? item.oprice : '--' }}</span>
              </td>
              <td style="border:1px solid #000;" colspan="1">
                <span>优惠价:{{ item.price ? item.price : '--' }}</span>
              </td>
              <td colspan="1" style="border:1px solid #000;">
                <span>
                  客人来源: {{changInfo.sourceAgreenidName ? changInfo.sourceAgreenidName : '--'}}
                </span>
              </td>
            </tr>
          </template>
        </template>


        <tr v-if="type == 2">
          <td style="border:1px solid #000;" colspan="2">
            <span>
              入住时间:
              <br />
              2019-09-02 02:00
            </span>
          </td>
          <td style="border:1px solid #000;" colspan="2">
            <span>
              预离时间:
              <br />
              2019-09-03 02:00
            </span>
          </td>
          <td colspan="1" style="border:1px solid #000;">
            <span>
              客人类型: 散客
            </span>
          </td>
        </tr>
        <tr v-else>
          <td style="border:1px solid #000;" colspan="2">
            <span>
              入住时间:
              <br />
              {{ changInfo.singleEntity.arrivalsTime ? changInfo.singleEntity.arrivalsTime : '2019-09-02 02:00' }}
            </span>
          </td>
          <td style="border:1px solid #000;" colspan="2">
            <span>
              预离时间:
              <br />
              {{ changInfo.singleEntity.predissociationTime ? changInfo.singleEntity.predissociationTime : '2019-09-03 02:00' }}
            </span>
          </td>
          <td colspan="1" style="border:1px solid #000;">
            <span>
              客人类型:
              <span v-if="changInfo">
                <span v-if="changInfo.singleEntity.sourceType == 0">散客</span>
                <span v-if="changInfo.singleEntity.sourceType == 1">
                  会员 等级：{{changInfo.singleEntity.memberLevelDetailEntity.levelName}} 卡号：{{changInfo.singleEntity.memberLevelDetailEntity.cardJustNo}}
                  余额：{{changInfo.singleEntity.memberLevelDetailEntity.balance}} 积分：{{changInfo.singleEntity.memberLevelDetailEntity.score}}
                </span>
                <span v-if="changInfo.singleEntity.sourceType == 2">
                  协议单位 {{changInfo.singleEntity.sourceName}}
                </span>
                <span v-if="changInfo.singleEntity.sourceType == 3">
                  中介 {{changInfo.singleEntity.sourceName}}
                </span>
              </span>
              <span v-else>散客</span>
            </span>
          </td>
        </tr>
        <tr>
          <td style="border:1px solid #000;" colspan="2"><span>早餐:无</span></td>
          <td v-if="type == 2" style="border:1px solid #000;" colspan="1">
            <span>
              押金: 微信:100
            </span>
          </td>
          <td v-else style="border:1px solid #000;" colspan="1">
            <span>
              押金: {{changInfo.singleEntity.depositSign ? changInfo.singleEntity.depositSign : '--'}}
            </span>
          </td>
          <td v-if="type == 2" style="border:1px solid #000;" colspan="2">
            <span>
              收款: 支付宝:100
            </span>
          </td>
          <td v-else style="border:1px solid #000;" colspan="2">
            <span>
              收款: {{changInfo.singleEntity.collectSign ? changInfo.singleEntity.collectSign : '--'}}
            </span>
          </td>
        </tr>


        <tr>
          <td style="border:1px solid #000;">房号</td>
          <td style="border:1px solid #000;">姓名</td>
          <td style="border:1px solid #000;">性别</td>
          <td style="border:1px solid #000;">电话</td>
          <td style="border:1px solid #000;">证件</td>
        </tr>

        <template v-if="type == 2">
          <tr>
            <td style="border:1px solid #000;">貂蝉</td>
            <td style="border:1px solid #000;">
              女
            </td>
            <td style="border:1px solid #000;">
              2001年10月21日
            </td>
            <td style="border:1px solid #000;">
              1588888xxx
            </td>
            <td style="border:1px solid #000;">
              居民身份证 411522xxxx2001
            </td>
          </tr>
        </template>

        <template v-else>
          <template v-for="(item,index) in changInfo.ruZhuPrintingPeopleVos">
            <tr>
              <td style="border:1px solid #000;">
                <span>{{ item.roomNum ? item.roomNum : '--'}}</span>
              </td>
              <td style="border:1px solid #000;">{{ item.name ? item.name : '貂蝉' }}</td>
              <td style="border:1px solid #000;">{{ item.sex ? item.sex : '--' }}</td>
              <td style="border:1px solid #000;">
                <span v-if="type == 2">
                  1588888xxx
                </span>
                <span v-else>
                  {{item.tel ? item.tel : '--'}}
                </span>
              </td>
              <td style="border:1px solid #000;">{{ item.certificateNumber ? item.certificateNumber : '--'}}</td>
            </tr>

          </template>
        </template>


        <tr>
          <td style="border:1px solid #000;" colspan="5">
            <span v-if="type == 2">
              备注: 需要牙刷两个
            </span>
            <span v-else>
              备注: {{changInfo.singleEntity.remarks ? changInfo.singleEntity.remarks : '无'}}
            </span>
          </td>
        </tr>
      </table>

      <div style="margin-left:10px;margin-top: 18px;">
        <div style="width:90%;">
          <div v-html="note"></div>
        </div>
      </div>
      <p class="panelone" style="margin-top: 10px;">
        <span>预定电话:</span>
        <span>{{ seller.tel ? seller.tel : '--' }}</span>
      </p>
      <p class="panelone">
        <span>酒店地址:</span>
        <span>{{ seller.address ? seller.address : '--' }}</span>
      </p>
      <div style="font-weight:bold;font-size:16px;margin-top:18px; ">
        <span class="signtext" style="width:40%;">确认签字:</span>
        <span style="width:55%;" class="inputspan"></span>
      </div>
    </div>
  </div>
</template>

<script>
  import moment from 'moment';
  export default {
    props: {
      note: {
        type: String,
        default: ''
      },
      // 区分是编辑模式还是正式模式 1正式模式  2测试模式
      type: {
        type: Number,
        default: 1
      },
    },
    data() {
      return {
        nowDate: '', // 当前日期
        nowTime: '', // 当前时间
        nowWeek: '', // 当前星期
        today: moment().format('YYYY-MM-DD'),
        seller: {
          tel: '',
          name: '',
          address: ''
        },
        user: {
          username: ''
        },
        changInfo: {
          sellerName: '',
          roomName: '',
          roomPrice: '',
          ruZhuPrintingRoomVos: [],
          ruZhuPrintingPeopleVos: [],
          peopleEntity: {
            name: '',
            sex: '',
            birthday: '',
            certificatesNumber: '',
            remarks: '',
            tel: '',
          },
          singleEntity: {
            sysNo: '',
            arrivalsTime: '',
            predissociationTime: '',
            depositSign: '',
            sourceType: '',
            collectSign: '',
            sourceName: '',
            memberLevelDetailEntity: {
              levelName: ''
            }
          },
        },
      };
    },
    methods: {
      setData(changInfo) {
        this.changInfo = changInfo
      },
      currentTime() {
        setInterval(this.getDate, 500);
      },
      getUser() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelprinttemplate/printInfo`),
          method: 'get'
        }).then(({
          data
        }) => {
          if (data.code === 0) {
            this.user = data.user;
            this.seller = data.seller;
            console.log(this.seller)
          }
        });
      },
      getDate: function() {
        var _this = this;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth() + 1;
        let dd = new Date().getDate();
        let week = new Date().getDay();
        let hh = new Date().getHours();
        let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
        if (week == 1) {
          this.nowWeek = '星期一';
        } else if (week == 2) {
          this.nowWeek = '星期二';
        } else if (week == 3) {
          this.nowWeek = '星期三';
        } else if (week == 4) {
          this.nowWeek = '星期四';
        } else if (week == 5) {
          this.nowWeek = '星期五';
        } else if (week == 6) {
          this.nowWeek = '星期六';
        } else {
          this.nowWeek = '星期日';
        }
        _this.nowTime = hh + ':' + mf;
        _this.nowDate = yy + '/' + mm + '/' + dd;
      }
    },
    mounted() {
      this.currentTime();
      this.getUser();
    }
  };
</script>

<style lang="scss">
</style>
